package com.company.ddd.application.service.impl;

import com.company.ddd.application.service.IUserService;
import com.company.ddd.domain.model.user.IUserRepository;
import com.company.ddd.domain.model.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * =================================
 * <p>
 * Created by cjj on 18-11-25.
 * <p>
 * 描述: 用户的业务调用
 */

@Service
public class UserService implements IUserService {

    private final IUserRepository userRepository;

    @Autowired
    public UserService(IUserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Override
    @Transactional(value = "setTransactionManager")
    public User test(String code) {
        User user = new User();
        user.setCode("test");
        user.setCode("password");
        userRepository.save(user);
        return userRepository.find(code);
    }

}
